package com.ruoyi.web.controller.school;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.student.domain.vo.SelectListVo;
import com.ruoyi.system.service.ISysDictTypeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController("SchoolDictController")
@RequestMapping("/admin/school/dict")
public class DictController extends BaseController {

    @Resource
    private ISysDictTypeService dictTypeService;

    /**
     * 获取民族下拉列表
     * @return
     */
    @GetMapping("/nation/selectlist")
    public AjaxResult getNation() {
        List<SysDictData> nationList = dictTypeService.selectDictDataByType("nation");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : nationList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictLabel());
            list.add(dto);
        }
        return success(list);
    }

    /**
     * 获取政治面貌下拉列表
     * @return
     */
    @GetMapping("/political/selectlist")
    public AjaxResult getPolitical() {
        List<SysDictData> politicalList = dictTypeService.selectDictDataByType("political");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : politicalList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictLabel());
            list.add(dto);
        }
        return success(list);
    }


    /**
     * 获取组织下拉列表
     * @return
     */
    @GetMapping("/group/selectlist")
    public AjaxResult getGroup() {
        List<SysDictData> groupList = dictTypeService.selectDictDataByType("group");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : groupList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictLabel());
            list.add(dto);
        }
        return success(list);
    }


    /**
     * 获取学制下拉列表
     * @return
     */
    @GetMapping("/studytime/selectlist")
    public AjaxResult getStudyTime() {
        List<SysDictData> studyTimeList = dictTypeService.selectDictDataByType("study_time");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : studyTimeList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictValue());
            list.add(dto);
        }
        return success(list);
    }


    /**
     * 获取学制下拉列表
     * @return
     */
    @GetMapping("/studystate/selectlist")
    public AjaxResult getStudyState() {
        List<SysDictData> studyStateList = dictTypeService.selectDictDataByType("study_state");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : studyStateList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictValue());
            list.add(dto);
        }
        return success(list);
    }

    /**
     * 获取校区
     * @return
     */
    @GetMapping("/campus/selectlist")
    public AjaxResult getCampus() {
        List<SysDictData> campusStateList = dictTypeService.selectDictDataByType("campus");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : campusStateList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictValue());
            list.add(dto);
        }
        return success(list);
    }


    /**
     * 获取性别下拉列表
     * @return
     */
    @GetMapping("/sex/selectlist")
    public AjaxResult getSex() {
        List<SysDictData> sexList = dictTypeService.selectDictDataByType("sex");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : sexList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictValue());
            list.add(dto);
        }
        return success(list);
    }


    /**
     * 获取困难下拉列表
     * @return
     */
    @GetMapping("/difficulty/selectlist")
    public AjaxResult getDifficulty() {
        List<SysDictData> sexList = dictTypeService.selectDictDataByType("difficulty");
        List<SelectListVo> list = new ArrayList<>();
        for (SysDictData data : sexList) {
            SelectListVo dto = new SelectListVo();
            dto.setLabel(data.getDictLabel());
            dto.setValue(data.getDictValue());
            list.add(dto);
        }
        return success(list);
    }





}
